#pragma once

#include <typedef.h>
//
#include <protocol.hpp>
#include <task_run.hpp>
#include <tcp_server.hpp>
#include <udp_recver.hpp>
#include <udp_sender.hpp>

class Connector
{
public:
	Connector();
	virtual ~Connector();
	static Connector* Instance();
	void Create(int port, TcpServerClient* (*pTcpClientCreator)());
	void Create(const char* ip, int port, UdpRecverClient* pUdpClient);
	void Send(int port, char* data, int size);
	void Send(int port, uint32_t data_type, char* data, int size);
	void SendTo(int port, char* data, int size);
	void SendTo(int port, uint32_t data_type, char* data, int size);

private:
	std::map<int, TcpServer*> m_Servers;
	std::map<int, UdpSender*> m_UdpSender;
	std::map<int, UdpRecver*> m_UdpRecver;
	Protocol m_Protocol;
	uint16_t m_DataSeq;
	int m_OutSize;
	char* m_OutData;
};